package Collection;

/**
 * @author yt1105
 * @version 1.0
 */
public class CollectionIterator {
    public static void main(String[] args) {
        int[] ints = {2,2,4};
        int[] errorNums = findErrorNums(ints);
        for (int i = 0; i < errorNums.length; i++) {
            System.out.println(errorNums[i]);
        }
    }

    public static int[] findErrorNums(int[] nums) {

        int[] tmp = new int[2];
        for (int i = 0; i < nums.length-1; i++) {
            if((nums[i]^nums[i+1])==0&&((i+2)<nums.length)){
                tmp[0]=nums[i];
                tmp[1]=nums[i]+1;
                break;
            }
            if((nums[i]^nums[i+1])==0&&((i+2)>=nums.length)){
                tmp[0]=nums[i];
                tmp[1]=nums[i]-1;
                break;
            }
        }
        return tmp;
    }
}
